package com.atguigu.a_hashset;

import java.util.HashSet;

public class Demo {
    public static void main(String[] args) {
        //创建学生对象
        Student stu1 = new Student("迪丽热巴", 18);
        Student stu2 = new Student("古力娜扎", 17);
        Student stu3 = new Student("马尔扎哈", 20);
        Student stu4 = new Student("迪丽热巴", 18);

        //创建集合对象添加元素
        HashSet<Student> hs = new HashSet<>();

        //添加元素
        hs.add(stu1);
        hs.add(stu2);
        hs.add(stu3);
        hs.add(stu4);


        System.out.println("hs.hashCode() = " + hs.hashCode());

        //遍历
        for (Student student : hs) {
            System.out.println("student = " + student);
        }

        System.out.println("\"重地\".hashCode() = " + "重地".hashCode());
        System.out.println("\"重地\".hashCode() = " + "重地".hashCode());

        System.out.println("\"通话\".hashCode() = " + "通话".hashCode());
    }
}
